package com.example.myapplication.fragment;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import android.app.Fragment;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.example.myapplication.R;

public class StaticFragmentActivity extends AppCompatActivity implements View.OnClickListener {

    private TextView textView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_static_fragment);
        findViewById(R.id.send_fragment_btn).setOnClickListener(this);
        textView = findViewById(R.id.write1);
    }

    @Override
    public void onClick(View view) {
        Bundle bundle=new Bundle();
        bundle.putString("msg",textView.getText().toString());
        StaticFragment staticFragment = new StaticFragment();
        staticFragment.setArguments(bundle);
        FragmentTransaction fragmentTransaction=getSupportFragmentManager().beginTransaction();
        fragmentTransaction.replace(R.id.fragment_static,staticFragment);
        fragmentTransaction.commit();
    }

}